import os
from urllib.parse import urlencode

import requests
from flask import Flask, jsonify, redirect, render_template, request, session
from oauthlib import oauth2

app = Flask(__name__,template_folder=".")
app.secret_key = os.urandom(24)

@app.route("/chat", methods=["GET"])
def chat():
    data = request.args.get("data")
    url = "http://api.qingyunke.com/api.php?key=free&appid=0&msg="+data
    r = requests.get(url)
    return jsonify(r.text)

@app.route("/", methods=["GET"])
def home():
    return render_template("robot.html")

if __name__ == "__main__":
    app.run(host="0.0.0.0", port=80, debug=True)